package com.project_doctor.handler;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.util.List;

public class LongListSerializer extends JsonSerializer<List<?>> {
    @Override
    public void serialize(List<?> value, JsonGenerator gen, SerializerProvider provider) throws IOException {
        gen.writeStartArray();
        for (Object item : value) {
            if (item instanceof Integer) {
                gen.writeNumber((Integer) item);
            } else if (item instanceof Long) {
                gen.writeNumber((Long) item);
            } else {
                gen.writeNull();
            }
        }
        gen.writeEndArray();
    }
}
